let a = [1, 5, 7, 8, 9, 5, 6, 7, 5, 3, 6, 8, 8, 8, 8];

function get_max_num(arr) {
  let obj = {},
    max;
  for (let i = 0; i < arr.length; i++) {
    if (obj.hasOwnProperty(arr[i])) {
      obj[arr[i]]["num"]++;
    } else {
      obj[arr[i]] = {
        num: 1,
      };
    }
  }
  console.log(obj);
  let maxIndex = Math.max.apply(
    Math,
    Object.keys(obj).map((item) => obj[item]["num"])
  );
  for (let key in obj) {
    if (obj[key]["num"] === maxIndex) {
      max = key;
    }
  }
  return max;
}

console.log(get_max_num(a));
